<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test Page for GownFull</title>
</head>
<body>
<h1>Get key</h1>
<p>
<textarea id="test" cols="80" rows="5"></textarea>
</p>
<p>
<textarea id="output" cols="80" rows="15" readonly="readonly"></textarea>
</p>
<p>
<input type="button" value="Clear" onClick="javascript:clear_output();" />
</p>
</body>
<script language="javascript">
function clear_output()
{
        var obj = document.getElementById('output');
	obj.value = '';
}
function debug(str)
{
	var obj = document.getElementById('output');
	obj.value += str;
}
function keydown(e)
{
	var key = e.which ? e.which : e.keyCode;
	debug('keydown: '+key+"\n");
	return true;
}
function keyup(e)
{
	var key = e.which ? e.which : e.keyCode;
	debug('keyup: '+key+"\n");
	return true;
}
function keypress(e)
{
	var key = e.which ? e.which : e.keyCode;
	debug('keypress: '+key+"\n");
	return true;
}
function mousemove(e)
{
	debug('mousemove: '+e.clientX+','+e.clientY+"\n");
}
function mouseup(e)
{
	debug('mouseup: '+e.clientX+','+e.clientY+"\n");
}
function mousedown(e)
{
	debug('mousedown: '+e.clientX+','+e.clientY+"\n");
}
var useragent = navigator.userAgent;
debug(useragent+"\n");
useragent = useragent.toLowerCase();
var isIE = (useragent.indexOf('msie') == -1) ? false : true;
var isFirefox = (useragent.indexOf('firefox') == -1) ? false : true;
var isOpera = (useragent.indexOf('opera') == -1) ? false : true;
var isKonqueror = (useragent.indexOf('konqueror') == -1) ? false : true;
var isMinimo = (useragent.indexOf('minimo') == -1) ? false : true;
var isSafari = (useragent.indexOf('safari') == -1) ? false : true;

var obj = document.getElementById('test');

if(isIE) debug("Running IE\n");
if(isFirefox) debug("Running Firefox\n");
if(isOpera) debug("Running Opera\n");
if(isKonqueror) debug("Running Konqueror\n");
if(isMinimo) debug("Running Minimo\n");
if(isSafari) debug("Running Safari\n");

if(isFirefox || isKonqueror || isMinimo || isSafari) {
	debug("using addEventListener\n");
	obj.addEventListener("keydown", function(e) { return keydown(e); },true);
	obj.addEventListener("keypress", function(e) { return keypress(e); },true);
	obj.addEventListener("keyup", function(e) { return keyup(e); },true);
//	obj.addEventListener("mousedown", function(e) { return mousedown(e); },true);
//	obj.addEventListener("mouseup", function(e) { return mouseup(e); },true);
//	obj.addEventListener("mousemove", function(e) { return mousemove(e); },true);
}
else { 
	debug("using obj.onxxxxx\n");
	obj.onkeydown = function() { return keydown(window.event); };
	obj.onkeypress = function() { return keypress(window.event); };
	obj.onkeyup = function() { return keyup(window.event); };
//	obj.onmousedown = function() { return mousedown(window.event); };
//	obj.onmouseup = function() { return mouseup(window.event); };
//	obj.onmousemove = function() { return mousemove(window.event); };
}
</script>
</html>
